#include "TexturesManager.h"
#include "Tools.h"
#include "Tools.h"

TexturesManager * TexturesManager::mInstance = 0;

TexturesManager::TexturesManager()
{

}

TexturesManager::TexturesManager(const TexturesManager&)
{

}

TexturesManager::~TexturesManager()
{

}

TexturesManager* TexturesManager::Instance()
{
	if(mInstance == NULL)
	{
		mInstance = new TexturesManager();
	}
	return mInstance;
}

bool TexturesManager::Initialize()
{
	//mTextures = new std::vector<Texture*>();
	//mDicoTextures = new std::map<std::string, Texture*>();


	return true;
}

void TexturesManager::Uninit()
{

}

void TexturesManager::AddTexture(std::string pName, ID3D11ShaderResourceView* pTexture)
{
	Texture* text = new Texture();
	text->Initialize(pTexture);
	mDicoTextures["SHADOW"] = text;
}

Texture* TexturesManager::GetTexture(std::string pFile)
{
	if(pFile == "SHADOW") 
	{
		return mDicoTextures["SHADOW"];
	}

	std::string file = std::string("Contents\\Textures\\") + pFile;
	Texture* result;
	std::map<std::string, Texture*>::iterator it = mDicoTextures.find(file);
	if(it == mDicoTextures.end())
	{
		result = new Texture();
		result->Initialize(file);
		mDicoTextures[file] = result;
	}
	else
	{
		result = mDicoTextures[file];
	}
	return result;
}
